-
Notifications
You must be signed in to change notification settings - Fork 38.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UDP protocol on connect agnhost command #98639
Conversation
@knabben: This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
f61f298
to
a9a87e3
Compare
} | ||
} | ||
|
||
if _, err = conn.Write([]byte("hostname\n")); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't assume the other end knows what hostname
means,
this is the problem with UDP, it is connection less, so we need to send something and the other reply in order to know the connection is ok.
What if we add another flag to be able to send data and we default it to hostname
or hello
cmd = []string{"/agnhost", "connect", fmt.Sprintf("%s:%d", addrTo, toPort), "--timeout=1s", "--protocol=udp","--data=hostname"}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, what about --udp-data
, since it's only used for UDP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, sounds much better, but keep it defaulted with some data
parseUDPErrorAndExit(err) | ||
} | ||
|
||
var buf = make([]byte, 1024) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have to verify that we actually received some data
kubernetes/test/e2e/network/service.go
Lines 536 to 561 in bae644e
n, err := con.Read(buf) | |
if err != nil { | |
ret.Error = err | |
neterr, ok := err.(net.Error) | |
if ok && neterr.Timeout() { | |
ret.Status = UDPTimeout | |
} else if strings.Contains(err.Error(), "connection refused") { | |
ret.Status = UDPRefused | |
} else { | |
ret.Status = UDPError | |
} | |
framework.Logf("Poke(%q): %v", url, err) | |
return ret | |
} | |
ret.Response = buf[0:n] | |
if params.Response != "" && string(ret.Response) != params.Response { | |
ret.Status = UDPBadResponse | |
ret.Error = fmt.Errorf("response does not match expected string: %q", string(ret.Response)) | |
framework.Logf("Poke(%q): %v", url, ret.Error) | |
return ret | |
} | |
ret.Status = UDPSuccess | |
framework.Logf("Poke(%q): success", url) | |
return ret |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raising an error when readBytes == 0
..
looks something that can be controlled on a flag i.e. --wait-response
. or even use a --udp-request
| --udp-response
..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you don't receive any bytes you can not known that the other side is receiving packets.
This is the same we discussed in slack regarding netcat, it just checks that the packet goes out, it doesn't mean it has been received, there is no ACK... 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you can return an error more descriptive "NO DATA RECEIVED" , and clarifiy that we can't guarantee the port is open
a9a87e3
to
3450c18
Compare
|
||
func init() { | ||
CmdConnect.Flags().DurationVar(&timeout, "timeout", time.Duration(0), "Maximum time before returning an error") | ||
CmdConnect.Flags().StringVar(&protocol, "protocol", "tcp", "The protocol to use to perform the connection, can be tcp or sctp") | ||
CmdConnect.Flags().StringVar(&protocol, "protocol", "tcp", "The protocol to use to perform the connection, can be tcp, udp or sctp") | ||
CmdConnect.Flags().StringVar(&udpData, "udp-data", "", "The UDP payload send to the server") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should put some data as default, "hello" or "hostname" can be valid since are used in our tests in a number of cases, I think hostname
is used in more places
3450c18
to
3eb63b5
Compare
/lgtm |
} | ||
|
||
// ensure the response from UDP server | ||
if readBytes == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, basically, we just have to make sure that the UDP server sends us some data back, the content of which is unimportant, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the more general approach .... we can complicate it more and add an option to match the answer ... but if we don´t check that at least we receive something we can´t know if the port was open or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm |
@knabben looks like we are adding a new "feature", please update test/images/agnhost/VERSION |
yeah, I forget that, sorry, I think you have to bump these 3 files: build/dependencies.yaml |
/hold some more files need to be updated. |
3eb63b5
to
ead0271
Compare
@dims bumped the files. Is this something that needs to be changed as well? https://github.com/kubernetes/kubernetes/blob/ead0271fcfbf0ee482e14151f338a6590e38e3f5/build/dependencies.yaml#L12 |
@@ -1,7 +1,7 @@ | |||
dependencies: | |||
# agnhost: bump this one first | |||
- name: "agnhost" | |||
version: "2.27" | |||
version: "2.28" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't change this just yet (since this version does not exist in the gcr repository)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh.. the dependencies job is failing with a test/images/agnhost/VERSION
mismatch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dims I think that is correct
agnhost: bump this one first
there is another place that is the one that has to be bumped later, once the promotion has been done
@@ -51,7 +51,7 @@ import ( | |||
func main() { | |||
rootCmd := &cobra.Command{ | |||
Use: "app", | |||
Version: "2.27", | |||
Version: "2.28", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think is correct, this has to be bumped first so we can promote it later
ead0271
to
79648f4
Compare
79648f4
to
f1da110
Compare
🤔 it fails
you can run it locally to find out what is the problem ... |
locally the command pass, let me rerun this again here. /test pull-kubernetes-dependencies |
/test pull-kubernetes-bazel-test |
/hold cancel please get an |
/lgtm |
/approve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
/lgtm
Now that connect
supports N=3 protocols, I think it'd be appropriate to refactor instead of continuing to copy-paste. It feels to me like there's plenty of untested room for subtle bugs between impls, but I won't block for that.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: claudiubelu, dims, knabben, spiffxp The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
yeah, but the networking tests are a minefield, and this only probes for connectivity , i.e. I submit something the other side replays something, there are other tests that need to check the content of the replay, i.e. to verify that the the pod belong to the expected hostname, so this is no a replacement for those. |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Adding UDP support on
agnhost connect
subcommand, so we can have standardized tooling for e2e network probe tests.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
With a host listening on UDP 8000:
Does this PR introduce a user-facing change?: